package it.univaq.mwt.business.impl;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import it.univaq.mwt.business.RuoloService;




import it.univaq.mwt.business.model.Gruppo;
import it.univaq.mwt.business.model.Ruolo;

import javax.annotation.Resource;
import javax.ejb.Remote;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;



/**
 * Session Bean implementation class EJBRuoli
 */

@Stateless
@Remote(RuoloService.class)
public class EJBRuolo implements RuoloService {

	@PersistenceContext(unitName="Yop-domain")
	private EntityManager em;
	
	@Resource
	private SessionContext etx;
	
    public EJBRuolo() {
        // TODO Auto-generated constructor stub
    }

	@Override
	public Ruolo getRuoloByName(String nome) {
		
		Query query = em.createQuery("select r from Ruolo r where r.nome =:nome");
		query.setParameter("nome", nome);
		
		Ruolo role = (Ruolo) query.getSingleResult();
		
		
		return role;
	}

}
